home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Concept 6
/
CD Concept 06.iso
/
mac
/
UTILITAIRE
/
RLaB
/
testmatrix
/
clement.r
< prev
next >
Wrap
Text File
|
1994-12-20
|
2KB
|
55 lines
//-------------------------------------------------------------------//
// Synopsis: Clement matrix - tridiagonal with zero diagonal entries.
// Syntax: A = clement ( N , K )
// Description:
// A is a tridiagonal matrix with zero diagonal entries and known
// eigenvalues. It is singular if N is odd. About 64 percent of
// the entries of the inverse are zero. The eigenvalues are
// plus and minus the numbers N-1, N-3, N-5, ..., (1 or 0).
// For K = 0 (the default) the matrix is unsymmetric, while for
// K = 1 it is symmetric.
// clement(N, 1) is diagonally similar to clement(N).
// Similar properties hold for tridiag(X,Y,Z) where
// Y = zeros(N,1). The eigenvalues still come in plus/minus pairs
// but they are not known explicitly.
// References:
// P.A. Clement, A class of triple-diagonal matrices for test
// purposes, SIAM Review, 1 (1959), pp. 50-52.
// O. Taussky and J. Todd, Another look at a matrix of Mark Kac,
// Linear Algebra and Appl., 150 (1991), pp. 341-360.
// This file is a translation of clement.m from version 2.0 of
// "The Test Matrix Toolbox for Matlab", described in Numerical
// Analysis Report No. 237, December 1993, by N. J. Higham.
//-------------------------------------------------------------------//
clement = function ( n , k )
{
local (n, k)
if (!exist (k)) { k = 0; }
n = n-1;
x = n:1:-1;
z = 1:n;
if (k == 0)
{
A = diag(x, -1) + diag(z, 1);
else
y = sqrt(x.*z);
A = diag(y, -1) + diag(y, 1);
}
return A;
};